/*
----------------------------------------------------------------------------------------------------
This source file is part of the Gamut Framework
Copyright (c) 2007 by Ryan Holcombe

This program is free software; you can redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
----------------------------------------------------------------------------------------------------
*/


#ifndef _GamutFramework_h_
#define _GamutFramework_h_

namespace Gamut
{

	/**
 		Initialises and runs the framework, main app should be inherited from this class

		\remarks
			App is run by calling go() and is set up to run in the following order:\n
			init()			- initialises the framework\n
			setup()			- allow the app to set up anything before rendering begins\n
			run()			- runs the loaded state, exits when no more states are loaded\n
			updateFrame()	- called each time through the loop by run()\n
			cleanup()		- processesing is over, app can clean up anything here\n
			destroy()		- clean up the framework here\n
	*/

	class Framework
	{
	private:
			
	public:
		/**
			\brief initialises the logger
		*/
		Framework();


		/**
			\brief destroys the logger
		*/
		virtual ~Framework();


		/**
			\brief runs the app by calling all necessary functions
		*/
		virtual void go();
		
		
		/**
			\brief registers all internal objects
		*/
		virtual void init();
		
		
		/**
			\brief to be defined in an inherited class (optional)
		*/
		virtual void setup() { }
		
		
		/**
			\brief runs the main game loop
		*/
		virtual void run();


		/**
			\brief called each time through the game loop by run()
			\return 0 to exit the run loop, 1 to continue
			\remarks this is a pure virtual function, must be inherited
		*/
		virtual bool updateFrame(double elapsed) = 0;
		
		
		/**
			\brief to be defined in an inherited class (optional)
		*/
		virtual void cleanup() { }
		
		
		/**
			\brief clean up all internal components and states
		*/
		virtual void destroy();
	};
}

#endif
